<!DOCTYPE html>


  <html class="dark page-post">


<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="utf-8">
  
  <title>Docker小结篇 | Poetry&#39;s Blog</title>

  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

  
    <meta name="keywords" content="Docker,部署,">
  

  <meta name="description" content="Docker是一个开源的应用容器引擎，而一个容器其实是一个虚拟化的独立的环境，让开发者可以打包他们的应用以及依赖包到一个可移植的容器中，然后发布到任何流行的 Linux 机器上，也可以实现虚拟化。容器是完全使用沙箱机制，相互之间不会有任何接口。   Docker 的局限性之一，它只能用在 64 位的操作系统上。  一、安装yum install docker        # CentOS 中安">
<meta name="keywords" content="Docker,部署">
<meta property="og:type" content="article">
<meta property="og:title" content="Docker小结篇">
<meta property="og:url" content="http://blog.poetries.top/2018/11/20/docker-summary/index.html">
<meta property="og:site_name" content="Poetry&#39;s Blog">
<meta property="og:description" content="Docker是一个开源的应用容器引擎，而一个容器其实是一个虚拟化的独立的环境，让开发者可以打包他们的应用以及依赖包到一个可移植的容器中，然后发布到任何流行的 Linux 机器上，也可以实现虚拟化。容器是完全使用沙箱机制，相互之间不会有任何接口。   Docker 的局限性之一，它只能用在 64 位的操作系统上。  一、安装yum install docker        # CentOS 中安">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2020-08-15T04:25:31.906Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Docker小结篇">
<meta name="twitter:description" content="Docker是一个开源的应用容器引擎，而一个容器其实是一个虚拟化的独立的环境，让开发者可以打包他们的应用以及依赖包到一个可移植的容器中，然后发布到任何流行的 Linux 机器上，也可以实现虚拟化。容器是完全使用沙箱机制，相互之间不会有任何接口。   Docker 的局限性之一，它只能用在 64 位的操作系统上。  一、安装yum install docker        # CentOS 中安">

  

  
    <link rel="icon" href="/favicon.ico">
  

  <link href="/css/styles.css?v=c114cbeddx" rel="stylesheet">
<link href="/css/other.css?v=c114cbeddx" rel="stylesheet">


  
    <link rel="stylesheet" href="/css/personal-style.css">
  

  

  
  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "//hm.baidu.com/hm.js?40b1f89aa80f2527b3db779c6898c879";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>


  
  <script type="text/javascript">
	(function(){
	    var bp = document.createElement('script');
	    var curProtocol = window.location.protocol.split(':')[0];
	    if (curProtocol === 'https') {
	        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
	    }
	    else {
	        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
	    }
	    var s = document.getElementsByTagName("script")[0];
	    s.parentNode.insertBefore(bp, s);
	})();
  </script>



  
    <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <link rel="stylesheet" href="//cdn.bootcss.com/font-awesome/4.3.0/css/font-awesome.min.css">
  

  <!-- 聊天系统 -->
  
    
   <link type="text/css" rel="stylesheet" href="/renxi/default.css">
   <style>
      #modal {
        position: static !important;
      }
      .filter {
        width: 100%;
        height: 100%;
        position: absolute;
        top: 0;
        left: 0;
        background: #fe5757;
        animation: colorChange 30s ease-in-out infinite;
        animation-fill-mode: both;
        mix-blend-mode: overlay;
      }
  
      @keyframes colorChange {
        0%, 100% {
            opacity: 0;
        }
        50% {
            opacity: .9;
        }
      }
   </style>
</head>
</html>
<body>
  
  
    <span id="toolbox-mobile" class="toolbox-mobile">导航</span>
  

  <div class="post-header CENTER">
   
  <div class="toolbox">
    <a class="toolbox-entry" href="/">
      <span class="toolbox-entry-text">导航</span>
      <i class="icon-angle-down"></i>
      <i class="icon-home"></i>
    </a>
    <ul class="list-toolbox">
      
        <li class="item-toolbox">
          <a
            class="CIRCLE"
            href="/archives/"
            rel="noopener noreferrer"
            target="_self"
            >
            博客
          </a>
        </li>
      
        <li class="item-toolbox">
          <a
            class="CIRCLE"
            href="/categories/"
            rel="noopener noreferrer"
            target="_self"
            >
            分类
          </a>
        </li>
      
        <li class="item-toolbox">
          <a
            class="CIRCLE"
            href="/tags/"
            rel="noopener noreferrer"
            target="_self"
            >
            标签
          </a>
        </li>
      
        <li class="item-toolbox">
          <a
            class="CIRCLE"
            href="/search/"
            rel="noopener noreferrer"
            target="_self"
            >
            搜索
          </a>
        </li>
      
        <li class="item-toolbox">
          <a
            class="CIRCLE"
            href="/link/"
            rel="noopener noreferrer"
            target="_self"
            >
            友链
          </a>
        </li>
      
        <li class="item-toolbox">
          <a
            class="CIRCLE"
            href="/about/"
            rel="noopener noreferrer"
            target="_self"
            >
            关于
          </a>
        </li>
      
    </ul>
  </div>


</div>


  <div id="toc" class="toc-article">
    <strong class="toc-title">文章目录<i class="iconfont toc-title" style="display:inline-block;color:#87998d;width:20px;height:20px;">&#xf004b;</i></strong>
    <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#一、安装"><span class="toc-text">一、安装</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#二、命令介绍"><span class="toc-text">二、命令介绍</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#三、服务管理"><span class="toc-text">三、服务管理</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#四、镜像管理"><span class="toc-text">四、镜像管理</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#4-1-通过容器创建镜像"><span class="toc-text">4.1 通过容器创建镜像</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#4-2-发布自己的镜像"><span class="toc-text">4.2 发布自己的镜像</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#4-3-镜像中安装软件"><span class="toc-text">4.3 镜像中安装软件</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#五、容器管理"><span class="toc-text">五、容器管理</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#5-1-容器服务管理"><span class="toc-text">5.1 容器服务管理</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#5-2-进入容器"><span class="toc-text">5.2 进入容器</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#六、使用Docker实战"><span class="toc-text">六、使用Docker实战</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#6-1-部署Nginx"><span class="toc-text">6.1 部署Nginx</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#6-2-部署MySQL"><span class="toc-text">6.2 部署MySQL</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#七、Docker私有仓库搭建"><span class="toc-text">七、Docker私有仓库搭建</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#7-1-部署registry"><span class="toc-text">7.1 部署registry</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#7-2-部署Humpback"><span class="toc-text">7.2 部署Humpback</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#八、参考资料"><span class="toc-text">八、参考资料</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#8-1-官方英文资源"><span class="toc-text">8.1 官方英文资源</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#8-2-中文资源"><span class="toc-text">8.2 中文资源</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#8-3-其它资源"><span class="toc-text">8.3 其它资源</span></a></li></ol></li></ol>
  </div>
  




<div class="content content-post CENTER">
   <!-- canvas 彩带 -->
<canvas id="evanyou" width="1302" height="678" style="position: fixed;width: 100%;height: 100%;top: 0;left:0;z-index:-1;"></canvas>

<article id="post-docker-summary" class="article article-type-post" itemprop="blogPost">
  <header class="article-header" style="position:relative;">
    <h1 class="post-title">Docker小结篇</h1>

    <div class="article-meta">
      <span>
        <i class="icon-calendar"></i>
        <span>2018.11.20</span>
      </span>

      
        <span class="article-author">
          <i class="icon-user"></i>
          <span>Poetry</span>
        </span>
      

      
  <span class="article-category">
    <i class="icon-list"></i>
    <a class="article-category-link" href="/categories/Back-end/">Back-end</a>
  </span>



      

      
      <i class="fa fa-eye"></i> 
        <span id="busuanzi_container_page_pv">
           &nbsp热度 <span id="busuanzi_value_page_pv">
           <i class="fa fa-spinner fa-spin"></i></span>℃
        </span>
      
      
       
          <span class="post-count">
            <i class="fa fa-file-word-o"></i>&nbsp
            <span>字数统计 3.2k字</span>
          </span>

          <span class="post-count">
            <i class="fa fa-columns"></i>&nbsp
            <span>阅读时长 14分</span>
          </span>
      
      
    </div>

    <i class="iconfont" id="toc-eye" style="display:inline-block;color:#b36619;position:absolute;top:0;right:0;cursor:pointer;
    font-size: 24px;">&#xe61c;</i>

  </header>

  <div class="article-content">
    
      <div id="container">
        <blockquote>
<p><code>Docker</code>是一个开源的应用容器引擎，而一个容器其实是一个虚拟化的独立的环境，让开发者可以打包他们的应用以及依赖包到一个可移植的容器中，然后发布到任何流行的 <code>Linux</code> 机器上，也可以实现虚拟化。容器是完全使用沙箱机制，相互之间不会有任何接口。</p>
</blockquote>
<ul>
<li><code>Docker</code> 的局限性之一，它只能用在 <code>64</code> 位的操作系统上。</li>
</ul>
<h2 id="一、安装"><a href="#一、安装" class="headerlink" title="一、安装"></a>一、安装</h2><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">yum install docker        <span class="comment"># CentOS 中安装</span></span><br><span class="line">apt-get install docker-ce <span class="comment"># Ubuntu 中安装</span></span><br><span class="line">pacman -S docker          <span class="comment"># Arch 中安装</span></span><br><span class="line">emerge --ask docker       <span class="comment"># Gentoo 中安装</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#=====================</span></span><br><span class="line"></span><br><span class="line">docker version      <span class="comment"># 通过查看版本，检查安装是否成功</span></span><br><span class="line"><span class="comment"># Client:</span></span><br><span class="line"><span class="comment">#  Version:         1.12.6</span></span><br><span class="line"><span class="comment">#  API version:     1.24</span></span><br><span class="line"><span class="comment">#  Package version: docker-1.12.6-55.gitc4618fb.el7.centos.x86_64</span></span><br><span class="line"><span class="comment">#  Go version:      go1.8.3</span></span><br><span class="line"><span class="comment">#  Git commit:      c4618fb/1.12.6</span></span><br><span class="line"><span class="comment">#  Built:           Thu Sep 21 22:33:52 2017</span></span><br><span class="line"><span class="comment">#  OS/Arch:         linux/amd64</span></span><br><span class="line"><span class="comment"># </span></span><br><span class="line"><span class="comment"># Server:</span></span><br><span class="line"><span class="comment">#  Version:         1.12.6</span></span><br><span class="line"><span class="comment">#  API version:     1.24</span></span><br><span class="line"><span class="comment">#  Package version: docker-1.12.6-55.gitc4618fb.el7.centos.x86_64</span></span><br><span class="line"><span class="comment">#  Go version:      go1.8.3</span></span><br><span class="line"><span class="comment">#  Git commit:      c4618fb/1.12.6</span></span><br><span class="line"><span class="comment">#  Built:           Thu Sep 21 22:33:52 2017</span></span><br><span class="line"><span class="comment">#  OS/Arch:         linux/amd64</span></span><br></pre></td></tr></table></figure>
<h2 id="二、命令介绍"><a href="#二、命令介绍" class="headerlink" title="二、命令介绍"></a>二、命令介绍</h2><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ docker --<span class="built_in">help</span></span><br><span class="line"></span><br><span class="line">管理命令:</span><br><span class="line">  container   管理容器</span><br><span class="line">  image       管理镜像</span><br><span class="line">  network     管理网络</span><br><span class="line">命令：</span><br><span class="line">  attach      介入到一个正在运行的容器</span><br><span class="line">  build       根据 Dockerfile 构建一个镜像</span><br><span class="line">  commit      根据容器的更改创建一个新的镜像</span><br><span class="line">  cp          在本地文件系统与容器中复制 文件/文件夹</span><br><span class="line">  create      创建一个新容器</span><br><span class="line">  <span class="built_in">exec</span>        在容器中执行一条命令</span><br><span class="line">  images      列出镜像</span><br><span class="line">  <span class="built_in">kill</span>        杀死一个或多个正在运行的容器    </span><br><span class="line">  logs        取得容器的日志</span><br><span class="line">  pause       暂停一个或多个容器的所有进程</span><br><span class="line">  ps          列出所有容器</span><br><span class="line">  pull        拉取一个镜像或仓库到 registry</span><br><span class="line">  push        推送一个镜像或仓库到 registry</span><br><span class="line">  rename      重命名一个容器</span><br><span class="line">  restart     重新启动一个或多个容器</span><br><span class="line">  rm          删除一个或多个容器</span><br><span class="line">  rmi         删除一个或多个镜像</span><br><span class="line">  run         在一个新的容器中执行一条命令</span><br><span class="line">  search      在 Docker Hub 中搜索镜像</span><br><span class="line">  start       启动一个或多个已经停止运行的容器</span><br><span class="line">  stats       显示一个容器的实时资源占用</span><br><span class="line">  stop        停止一个或多个正在运行的容器</span><br><span class="line">  tag         为镜像创建一个新的标签</span><br><span class="line">  top         显示一个容器内的所有进程</span><br><span class="line">  unpause     恢复一个或多个容器内所有被暂停的进程</span><br></pre></td></tr></table></figure>
<h2 id="三、服务管理"><a href="#三、服务管理" class="headerlink" title="三、服务管理"></a>三、服务管理</h2><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">service docker start       <span class="comment"># 启动 docker 服务，守护进程</span></span><br><span class="line">service docker stop        <span class="comment"># 停止 docker 服务</span></span><br><span class="line">chkconfig docker on        <span class="comment"># 设置为开机启动</span></span><br></pre></td></tr></table></figure>
<h2 id="四、镜像管理"><a href="#四、镜像管理" class="headerlink" title="四、镜像管理"></a>四、镜像管理</h2><p>镜像可以看做我们平时装系统的镜像，里面就是一个运行环境。</p>
<figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">docker pull centos:latest  <span class="comment"># 从docker.io中下载centos镜像到本地</span></span><br><span class="line">docker images              <span class="comment"># 查看已下载的镜像</span></span><br><span class="line">docker rm image_id         <span class="comment"># 删除镜像，指定镜像id</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 删除所有镜像</span></span><br><span class="line"><span class="comment"># none 默认为 docker.io</span></span><br><span class="line">docker rmi $(docker images | grep none | awk <span class="string">'&#123;print $3&#125;'</span> | sort -r)</span><br><span class="line"></span><br><span class="line"><span class="comment"># 连接进行进入命令行模式，exit命令退出。</span></span><br><span class="line">docker run -t -i nginx:latest /bin/bash</span><br></pre></td></tr></table></figure>
<h3 id="4-1-通过容器创建镜像"><a href="#4-1-通过容器创建镜像" class="headerlink" title="4.1 通过容器创建镜像"></a>4.1 通过容器创建镜像</h3><p>我们可以通过以下两种方式对镜像进行更改。</p>
<ol>
<li>从已经创建的容器中更新镜像，并且提交这个镜像</li>
<li>使用<code>Dockerfile</code> 指令来创建一个新的镜像</li>
</ol>
<p>下面通过已存在的容器创建一个新的镜像。</p>
<figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">docker commit -m=<span class="string">"First Docker"</span> -a=<span class="string">"wcjiang"</span> a6b0a6cfdacf wcjiang/nginx:v1.2.1</span><br></pre></td></tr></table></figure>
<p><strong>上面命令参数说明</strong>：</p>
<ul>
<li><code>-m</code> 提交的描述信息</li>
<li><code>-a</code> 指定镜像作者</li>
<li><code>a6b0a6cfdacf</code> 记住这个是容器id，不是镜像id</li>
<li><code>wcjiang/nginx:v1.2.1</code> 创建的目标镜像名</li>
</ul>
<h3 id="4-2-发布自己的镜像"><a href="#4-2-发布自己的镜像" class="headerlink" title="4.2 发布自己的镜像"></a>4.2 发布自己的镜像</h3><ol>
<li>在<a href="https://www.docker.com/" target="_blank" rel="noopener">Docker</a> 注册账户，发布的镜像都在<a href="https://cloud.docker.com/repository/list" target="_blank" rel="noopener">这个页面里</a>展示</li>
<li>将上面做的镜像<code>nginx</code>，起个新的名字<code>nginx-test</code></li>
</ol>
<figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">docker tag wcjiang/nginx:v1.2.1 wcjiang/nginx-test:lastest</span><br></pre></td></tr></table></figure>
<ol start="3">
<li>登录<code>docker</code></li>
</ol>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">docker login</span><br></pre></td></tr></table></figure>
<ol start="4">
<li>上传<code>nginx-test</code>镜像</li>
</ol>
<figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">docker push wcjiang/nginx-test:lastest</span><br><span class="line"><span class="comment"># The push refers to a repository [docker.io/wcjiang/nginx-test]</span></span><br><span class="line"><span class="comment"># 2f5c6a3c22e3: Mounted from wcjiang/nginx</span></span><br><span class="line"><span class="comment"># cf516324493c: Mounted from wcjiang/nginx</span></span><br><span class="line"><span class="comment"># lastest: digest: sha256:73ae804b2c60327d1269aa387cf782f664bc91da3180d10dbd49027d7adaa789 size: 736</span></span><br></pre></td></tr></table></figure>
<h3 id="4-3-镜像中安装软件"><a href="#4-3-镜像中安装软件" class="headerlink" title="4.3 镜像中安装软件"></a>4.3 镜像中安装软件</h3><blockquote>
<p>通常情况下，使用<code>docker</code>官方镜像，如 <code>mysql</code>镜像，默认情况下镜像中啥软件也没有，通过下面命令安装你所需要的软件：</p>
</blockquote>
<figure class="highlight bash"><table><tr><td class="code"><pre><span class="line"><span class="comment"># 第一次需要运行这个命令，确保源的索引是最新的</span></span><br><span class="line"><span class="comment"># 同步 /etc/apt/sources.list 和 /etc/apt/sources.list.d 中列出的源的索引</span></span><br><span class="line">apt-get update</span><br><span class="line"><span class="comment"># 做过上面更新同步之后，可以运行下面的命令了</span></span><br><span class="line">apt-get install vim</span><br></pre></td></tr></table></figure>
<blockquote>
<p>如果你安装了<code>CentOS</code>或者<code>Ubuntu</code>系统可以进入系统安装相关软件</p>
</blockquote>
<figure class="highlight bash"><table><tr><td class="code"><pre><span class="line"><span class="comment"># 进入到centos7镜像系统</span></span><br><span class="line">docker run -i -t centos:7 /bin/bash</span><br><span class="line">yum update</span><br><span class="line">yum install vim</span><br></pre></td></tr></table></figure>
<h2 id="五、容器管理"><a href="#五、容器管理" class="headerlink" title="五、容器管理"></a>五、容器管理</h2><p>容器就像一个类的实例</p>
<figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">docker run centos <span class="built_in">echo</span> <span class="string">"hello world"</span>  <span class="comment"># 在docker容器中运行hello world!</span></span><br><span class="line">docker run centos yum install -y wget <span class="comment"># 在docker容器中，安装wget软件</span></span><br><span class="line">docker ps                           <span class="comment"># 列出包括未运行的容器</span></span><br><span class="line">docker ps -a                        <span class="comment"># 查看所有容器(包括正在运行和已停止的)</span></span><br><span class="line">docker logs my-nginx                <span class="comment"># 查看 my-nginx 容器日志</span></span><br><span class="line"></span><br><span class="line">docker run -i -t centos /bin/bash   <span class="comment"># 启动一个容器</span></span><br><span class="line">docker inspect centos     <span class="comment"># 检查运行中的镜像</span></span><br><span class="line">docker commit 8bd centos  <span class="comment"># 保存对容器的修改</span></span><br><span class="line">docker commit -m <span class="string">"n changed"</span> my-nginx my-nginx-image <span class="comment"># 使用已经存在的容器创建一个镜像</span></span><br><span class="line">docker inspect -f &#123;&#123;.State.Pid&#125;&#125; 44fc0f0582d9 <span class="comment"># 获取id为 44fc0f0582d9 的PID进程编号</span></span><br></pre></td></tr></table></figure>
<h3 id="5-1-容器服务管理"><a href="#5-1-容器服务管理" class="headerlink" title="5.1 容器服务管理"></a>5.1 容器服务管理</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">docker run -itd --name my-nginx2 nginx <span class="comment"># 通过nginx镜像，【创建】容器名为 my-nginx2 的容器</span></span><br><span class="line">docker start my-nginx --restart=always    <span class="comment"># 【启动策略】一个已经存在的容器启动添加策略</span></span><br><span class="line">                               <span class="comment"># no - 容器不重启</span></span><br><span class="line">                               <span class="comment"># on-failure - 容器推出状态非0时重启</span></span><br><span class="line">                               <span class="comment"># always - 始终重启</span></span><br><span class="line">docker start my-nginx               <span class="comment"># 【启动】一个已经存在的容器</span></span><br><span class="line">docker restart my-nginx             <span class="comment"># 【重启】容器</span></span><br><span class="line">docker stop my-nginx                <span class="comment"># 【停止运行】一个容器</span></span><br><span class="line">docker <span class="built_in">kill</span> my-nginx                <span class="comment"># 【杀死】一个运行中的容器</span></span><br><span class="line">docker rename my-nginx new-nginx    <span class="comment"># 【重命名】容器</span></span><br><span class="line">docker rm new-nginx                 <span class="comment"># 【删除】容器</span></span><br></pre></td></tr></table></figure>
<h3 id="5-2-进入容器"><a href="#5-2-进入容器" class="headerlink" title="5.2 进入容器"></a>5.2 进入容器</h3><ol>
<li>创建一个守护状态的<code>Docker</code>容器</li>
</ol>
<figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">docker run -itd my-nginx /bin/bash</span><br></pre></td></tr></table></figure>
<ol start="2">
<li>使用<code>docker ps</code>查看到该容器信息</li>
</ol>
<figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">docker ps</span><br><span class="line"><span class="comment"># CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES</span></span><br><span class="line"><span class="comment"># 6bd0496da64f        nginx               "/bin/bash"         20 seconds ago      Up 18 seconds       80/tcp              high_shirley</span></span><br></pre></td></tr></table></figure>
<ol start="3">
<li>使用<code>docker exec</code>命令进入一个已经在运行的容器</li>
</ol>
<figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">docker <span class="built_in">exec</span> -it 6bd0496da64f /bin/bash</span><br></pre></td></tr></table></figure>
<blockquote>
<p>通常有下面几种方式进入<code>Docker</code>的容器，推荐使用<code>exec</code>，使用<code>attach</code>一直进入失败。</p>
</blockquote>
<ul>
<li>使用<code>docker attach</code></li>
<li>使用<code>SSH</code> <a href="http://www.oschina.net/translate/why-you-dont-need-to-run-sshd-in-docker?cmp" target="_blank" rel="noopener">为什么不需要在 Docker 容器中运行 sshd</a></li>
<li>使用<code>nsenter</code>进入Docker容器，<a href="https://github.com/jpetazzo/nsenter" target="_blank" rel="noopener">nsenter官方仓库</a></li>
<li>使用<code>docker exec</code>，在<code>1.3.*</code>之后提供了一个新的命令<code>exec</code>用于进入容器</li>
</ul>
<h2 id="六、使用Docker实战"><a href="#六、使用Docker实战" class="headerlink" title="六、使用Docker实战"></a>六、使用Docker实战</h2><h3 id="6-1-部署Nginx"><a href="#6-1-部署Nginx" class="headerlink" title="6.1 部署Nginx"></a>6.1 部署Nginx</h3><p>1.在 <code>docker hub</code> 中查找 <code>nginx</code>相关镜像。</p>
<figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ docker search nginx</span><br><span class="line"></span><br><span class="line"><span class="comment"># INDEX       NAME                                                             DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED</span></span><br><span class="line"><span class="comment"># docker.io   docker.io/nginx                                                  Official build of Nginx.                        7006      [OK]</span></span><br><span class="line"><span class="comment"># docker.io   docker.io/jwilder/nginx-proxy                                    Automated Nginx reverse proxy for docker c...   1137                 [OK]</span></span><br><span class="line"><span class="comment"># docker.io   docker.io/richarvey/nginx-php-fpm                                Container running Nginx + PHP-FPM capable ...   453                  [OK]</span></span><br><span class="line"><span class="comment"># docker.io   docker.io/jrcs/letsencrypt-nginx-proxy-companion                 LetsEncrypt container to use with nginx as...   230                  [OK]</span></span><br><span class="line"><span class="comment"># docker.io   docker.io/kong                                                   Open-source Microservice &amp; API Management ...   116       [OK]</span></span><br><span class="line"><span class="comment"># docker.io   docker.io/webdevops/php-nginx                                    Nginx with PHP-FPM                              90                   [OK]</span></span><br></pre></td></tr></table></figure>
<p>2.拉取官方镜像，其中上面的非官方镜像是用户们根据自己的需要制作的镜像，方便大家的使用。</p>
<figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ docker pull nginx</span><br><span class="line"><span class="comment"># Using default tag: latest</span></span><br><span class="line"><span class="comment"># Trying to pull repository docker.io/library/nginx ...</span></span><br><span class="line"><span class="comment"># latest: Pulling from docker.io/library/nginx</span></span><br><span class="line"><span class="comment"># bc95e04b23c0: Pull complete</span></span><br><span class="line"><span class="comment"># 110767c6efff: Pull complete</span></span><br><span class="line"><span class="comment"># f081e0c4df75: Pull complete</span></span><br><span class="line"><span class="comment"># Digest: sha256:004ac1d5e791e705f12a1</span></span><br></pre></td></tr></table></figure>
<p>3.利用这个镜像启动一个新的容器</p>
<figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">docker run --name my-nginx -d -p 8080:80 nginx</span><br><span class="line"><span class="comment"># faaed6a2d63af248961aab59713e515c76aea447</span></span><br></pre></td></tr></table></figure>
<p>4.查看容器运行日志</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">docker logs my-nginx</span><br></pre></td></tr></table></figure>
<p>启动一个更复杂<code>Nginx</code>的例子：</p>
<figure class="highlight bash"><table><tr><td class="code"><pre><span class="line"><span class="comment"># 上面的命令将本地文件中的 nginx.conf 配置文件挂载到容器，并且将要展示的静态页面也挂载到容器。</span></span><br><span class="line">docker run --name my-nginx \ </span><br><span class="line">    -v /host/path/nginx.conf:/etc/nginx/nginx.conf:ro \</span><br><span class="line">    -v /some/html:/usr/share/nginx/html:ro \</span><br><span class="line">    -p 8080:80 \</span><br><span class="line">    -d nginx</span><br></pre></td></tr></table></figure>
<p><code>-v</code> 参数语法为 <code>-v host dir:container dir[:ro|rw]</code></p>
<ul>
<li><code>--name</code> 为容器取一个名字</li>
<li><code>-p</code> 参数语法为 <code>-p host port:container port</code>; <code>-p 8080:80</code> 将主机上的<code>8080</code>端口绑定到容器上的80端口，因此在主机中访问<code>8080</code>端口时其实就是访问 <code>nginx</code> 容器的<code>80</code>端口</li>
<li><code>-d</code> 后台运行容器</li>
</ul>
<h3 id="6-2-部署MySQL"><a href="#6-2-部署MySQL" class="headerlink" title="6.2 部署MySQL"></a>6.2 部署MySQL</h3><blockquote>
<p>拉取官方的镜像，标签为<code>5.7</code>，<a href="https://docs.docker.com/samples/library/mysql/#-via-docker-stack-deploy-or-docker-compose" target="_blank" rel="noopener">Docker官方资料</a>、<a href="https://dev.mysql.com/doc/refman/8.0/en/docker-mysql-more-topics.html" target="_blank" rel="noopener">MySQL 官方资料</a></p>
</blockquote>
<figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">docker pull mysql:5.7</span><br><span class="line"><span class="comment"># Trying to pull repository docker.io/library/mysql ...</span></span><br><span class="line"><span class="comment"># 5.7: Pulling from docker.io/library/mysql</span></span><br><span class="line"><span class="comment"># 85b1f47fba49: Already exists</span></span><br><span class="line"><span class="comment"># f34057997f40: Pull complete</span></span><br><span class="line"><span class="comment"># ....</span></span><br><span class="line"><span class="comment"># Digest: sha256:bfb22e93ee87c6aab6c1c9a4e70f28fa289f9ffae9fe8e173</span></span><br></pre></td></tr></table></figure>
<p><strong>创建目录</strong></p>
<ul>
<li><code>data</code>目录将映射为<code>mysql</code>容器配置的数据文件存放路径</li>
<li><code>logs</code>目录将映射为<code>mysql</code>容器的日志目录</li>
<li><code>conf</code>目录里的配置文件将映射为<code>mysql</code>容器的配置文件</li>
</ul>
<figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">mkdir -p ~/mysql/data ~/mysql/logs ~/mysql/conf</span><br></pre></td></tr></table></figure>
<p><strong>运行容器</strong></p>
<figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">docker run --name my-mysql \ </span><br><span class="line">-p 3306:3306 \ </span><br><span class="line">-v <span class="variable">$PWD</span>/conf/my.cnf:/etc/mysql/my.cnf \ </span><br><span class="line">-v <span class="variable">$PWD</span>/logs:/logs \ </span><br><span class="line">-v <span class="variable">$PWD</span>/data:/mysql_data \ </span><br><span class="line">-e MYSQL_ROOT_PASSWORD=123456 \ </span><br><span class="line">-d mysql:5.7</span><br></pre></td></tr></table></figure>
<ul>
<li><code>-p 3306:3306</code>：将容器的<code>3306</code>端口映射到主机的<code>3306</code>端口</li>
<li><code>-v $PWD/conf/my.cnf:/etc/mysql/my.cnf</code>：将主机当前目录下的<code>conf/my.cnf</code>挂载到容器的<code>/etc/mysql/my.cnf</code></li>
<li><code>-v $PWD/logs:/logs</code>：将主机当前目录下的<code>logs</code>目录挂载到容器的<code>/logs</code></li>
<li><code>-v $PWD/data:/mysql_data</code>：将主机当前目录下的<code>data</code>目录挂载到容器的<code>/mysql_data</code></li>
<li><code>-e MYSQL_ROOT_PASSWORD=123456</code>：初始化root用户的密码</li>
</ul>
<h2 id="七、Docker私有仓库搭建"><a href="#七、Docker私有仓库搭建" class="headerlink" title="七、Docker私有仓库搭建"></a>七、Docker私有仓库搭建</h2><blockquote>
<p>通过官方提供的私有仓库镜像<code>registry</code>来搭建私有仓库。通过 <a href="https://humpback.github.io" target="_blank" rel="noopener">humpback</a> 快速搭建轻量级的Docker容器云管理平台。关于仓库配置说明请参见<a href="https://github.com/docker/distribution/blob/master/docs/configuration.md" target="_blank" rel="noopener">configuration.md</a></p>
</blockquote>
<h3 id="7-1-部署registry"><a href="#7-1-部署registry" class="headerlink" title="7.1 部署registry"></a>7.1 部署registry</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">docker pull registry:2.6.2</span><br></pre></td></tr></table></figure>
<blockquote>
<p>为了定制一些配置，和在 <a href="https://humpback.github.io" target="_blank" rel="noopener">humpback</a> 中使用，我们还需要提供一个定制化的配置文件（使用yml来编写配置文件），文件放在<code>/etc/docker/registry/config.yml</code>，如下：</p>
</blockquote>
<figure class="highlight yml"><table><tr><td class="code"><pre><span class="line"><span class="attr">version:</span> <span class="number">0.1</span></span><br><span class="line"><span class="attr">log:</span></span><br><span class="line">  <span class="attr">fields:</span></span><br><span class="line">    <span class="attr">service:</span> <span class="string">registry</span></span><br><span class="line"><span class="attr">storage:</span> </span><br><span class="line">  <span class="attr">cache:</span></span><br><span class="line">    <span class="attr">blobdescriptor:</span> <span class="string">inmemory</span></span><br><span class="line">  <span class="attr">filesystem:</span></span><br><span class="line">    <span class="attr">rootdirectory:</span> <span class="string">/var/lib/registry</span></span><br><span class="line"><span class="attr">http:</span></span><br><span class="line">  <span class="attr">addr:</span> <span class="string">:7000</span></span><br><span class="line">  <span class="attr">secret:</span> <span class="string">docker-registry</span></span><br><span class="line">  <span class="attr">headers:</span></span><br><span class="line">    <span class="attr">X-Content-Type-Options:</span> <span class="string">[nosniff]</span></span><br><span class="line">    <span class="attr">Access-Control-Allow-Headers:</span> <span class="string">['*']</span></span><br><span class="line">    <span class="attr">Access-Control-Allow-Origin:</span> <span class="string">['*']</span></span><br><span class="line">    <span class="attr">Access-Control-Allow-Methods:</span> <span class="string">['GET,POST,PUT,DELETE']</span></span><br><span class="line"><span class="attr">health:</span></span><br><span class="line">  <span class="attr">storagedriver:</span></span><br><span class="line">    <span class="attr">enabled:</span> <span class="literal">true</span></span><br><span class="line">    <span class="attr">interval:</span> <span class="string">10s</span></span><br><span class="line">    <span class="attr">threshold:</span> <span class="number">3</span></span><br></pre></td></tr></table></figure>
<blockquote>
<p>创建容器并运行，创建成功之后，可访问 <code>http://192.168.99.100:7000/v2/</code>，来检查仓库是否正常运行，当返回 <code>{}</code> 时，表示部署成功。</p>
</blockquote>
<figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">docker run -d -p 7000:7000 --restart=always \</span><br><span class="line"> -v /var/lib/registry/:/var/lib/registry/ \</span><br><span class="line"> -v /etc/docker/registry/config.yml:/etc/docker/registry/config.yml \</span><br><span class="line"> --name humpback-registry \</span><br><span class="line"> registry:2.6.2</span><br></pre></td></tr></table></figure>
<p>推送镜像到私有仓库</p>
<figure class="highlight bash"><table><tr><td class="code"><pre><span class="line"><span class="comment"># 从官方仓库拉取一个镜像</span></span><br><span class="line">docker pull nginx:1.13</span><br><span class="line"><span class="comment"># 为镜像 `nginx:1.13` 创建一个新标签 `192.168.99.100:7000/test-nginx:1.13`</span></span><br><span class="line">docker tag nginx:1.13 192.168.99.100:7000/<span class="built_in">test</span>-nginx:1.13</span><br><span class="line"><span class="comment"># 推送到私有仓库中</span></span><br><span class="line">docker push 192.168.99.100:7000/<span class="built_in">test</span>-nginx:1.13</span><br><span class="line"><span class="comment"># The push refers to a repository [192.168.99.100:7000/test-nginx]</span></span><br><span class="line"><span class="comment"># Get https://192.168.99.100:7000/v1/_ping: http: server gave HTTP response to HTTPS client</span></span><br></pre></td></tr></table></figure>
<blockquote>
<p>在推送到的时候报错误，默认是使用<code>https</code>提交，这个搭建的默认使用的是 <code>http</code>，解决方法两个：</p>
</blockquote>
<ol>
<li>创建一个<code>https</code>映射</li>
<li>将仓库地址加入到不安全的仓库列表中</li>
</ol>
<p>我们使用第二种方法，加入到不安全的仓库列表中，修改docker配置文件<code>vi /etc/docker/daemon.json</code> 添加 <code>insecure-registries</code>配置信息。</p>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line">&#123;</span><br><span class="line">  <span class="comment">//... 其他配置项</span></span><br><span class="line">  <span class="comment">//关键配置项，将仓库将入到不安全的仓库列表中</span></span><br><span class="line">  <span class="string">"insecure-registries"</span>:[ </span><br><span class="line">    <span class="string">"192.168.99.100:7000"</span></span><br><span class="line">  ]</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<blockquote>
<p>重启服务 <code>service docker restart</code>，默认情况下 push 是会报如下错误的：</p>
</blockquote>
<figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">docker push 192.168.99.100:7000/<span class="built_in">test</span>-nginx:1.13</span><br><span class="line"><span class="comment"># The push refers to a repository [192.168.99.100:7000/test-nginx]</span></span><br><span class="line"><span class="comment"># a1a53f8d99b5: Retrying in 1 second</span></span><br><span class="line"><span class="comment"># ...</span></span><br><span class="line"><span class="comment"># received unexpected HTTP status: 500 Internal Server Error</span></span><br></pre></td></tr></table></figure>
<blockquote>
<p>上面错误是<code>SELinux</code>强制访问控制安全系统，阻止导致的错误，通过下面方法禁用<code>SELinux</code>之后就可以push了。</p>
</blockquote>
<figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">setenforce 0  </span><br><span class="line">getenforce   </span><br><span class="line"><span class="comment"># Permissive</span></span><br></pre></td></tr></table></figure>
<h3 id="7-2-部署Humpback"><a href="#7-2-部署Humpback" class="headerlink" title="7.2 部署Humpback"></a>7.2 部署Humpback</h3><blockquote>
<p>首先创建放持久化数据文件夹，<code>mkdir -p /opt/app/humpback-web</code>，里面存放持久化数据文件，会存储站点管理和分组信息，启动后请妥善保存。</p>
</blockquote>
<figure class="highlight bash"><table><tr><td class="code"><pre><span class="line"><span class="comment"># 创建放持久化数据文件夹</span></span><br><span class="line">mkdir -p /opt/app/humpback-web</span><br><span class="line"><span class="comment"># 下载humpback-web镜像到本地</span></span><br><span class="line">docker pull humpbacks/humpback-web:1.0.0</span><br><span class="line"><span class="comment"># 启动 humpback-web 容器，将容器命名为 humpback-web</span></span><br><span class="line">docker run -d --net=host --restart=always \</span><br><span class="line"> -e HUMPBACK_LISTEN_PORT=7001 \</span><br><span class="line"> -v /opt/app/humpback-web/dbFiles:/humpback-web/dbFiles \</span><br><span class="line"> --name humpback-web \</span><br><span class="line"> humpbacks/humpback-web:1.0.0</span><br></pre></td></tr></table></figure>
<blockquote>
<p>访问站点，打开浏览器输入：·<a href="http://192.168.99.100:7001·" target="_blank" rel="noopener">http://192.168.99.100:7001·</a> ，默认账户：<code>admin</code> 密码：<code>123456</code></p>
</blockquote>
<h2 id="八、参考资料"><a href="#八、参考资料" class="headerlink" title="八、参考资料"></a>八、参考资料</h2><h3 id="8-1-官方英文资源"><a href="#8-1-官方英文资源" class="headerlink" title="8.1 官方英文资源"></a>8.1 官方英文资源</h3><ul>
<li>Docker官网：<a href="http://www.docker.com" target="_blank" rel="noopener">http://www.docker.com</a></li>
<li>Docker windows入门：<a href="https://docs.docker.com/windows/" target="_blank" rel="noopener">https://docs.docker.com/windows/</a></li>
<li>Docker Linux 入门：<a href="https://docs.docker.com/linux/" target="_blank" rel="noopener">https://docs.docker.com/linux/</a></li>
<li>Docker mac 入门：<a href="https://docs.docker.com/mac/" target="_blank" rel="noopener">https://docs.docker.com/mac/</a></li>
<li>Docker 用户指引：<a href="https://docs.docker.com/engine/userguide/" target="_blank" rel="noopener">https://docs.docker.com/engine/userguide/</a></li>
<li>Docker 官方博客：<a href="http://blog.docker.com/" target="_blank" rel="noopener">http://blog.docker.com/</a></li>
<li>Docker Hub: <a href="https://hub.docker.com/" target="_blank" rel="noopener">https://hub.docker.com/</a></li>
<li>Docker开源： <a href="https://www.docker.com/open-source" target="_blank" rel="noopener">https://www.docker.com/open-source</a></li>
</ul>
<h3 id="8-2-中文资源"><a href="#8-2-中文资源" class="headerlink" title="8.2 中文资源"></a>8.2 中文资源</h3><ul>
<li>Docker中文网站：<a href="http://www.docker.org.cn" target="_blank" rel="noopener">http://www.docker.org.cn</a></li>
<li>Docker中文文档：<a href="http://www.dockerinfo.net/document" target="_blank" rel="noopener">http://www.dockerinfo.net/document</a></li>
<li>Docker安装手册：<a href="http://www.docker.org.cn/book/install.html" target="_blank" rel="noopener">http://www.docker.org.cn/book/install.html</a></li>
<li>一小时Docker教程 ：<a href="https://blog.csphere.cn/archives/22" target="_blank" rel="noopener">https://blog.csphere.cn/archives/22</a></li>
<li>Docker中文指南：<a href="http://www.widuu.com/chinese_docker/index.html" target="_blank" rel="noopener">http://www.widuu.com/chinese_docker/index.html</a></li>
</ul>
<h3 id="8-3-其它资源"><a href="#8-3-其它资源" class="headerlink" title="8.3 其它资源"></a>8.3 其它资源</h3><ul>
<li><a href="https://github.com/eon01/DockerCheatSheet" target="_blank" rel="noopener">Docker 快速手册！</a></li>
<li><a href="http://www.runoob.com/docker/docker-tutorial.html" target="_blank" rel="noopener">Docker 教程</a></li>
<li><a href="http://blog.csdn.net/zhangchao19890805/article/details/52756865" target="_blank" rel="noopener">MySQL Docker 单一机器上如何配置自动备份</a></li>
<li><a href="https://segmentfault.com/t/docker" target="_blank" rel="noopener">https://segmentfault.com/t/docker</a></li>
<li><a href="https://github.com/docker/docker" target="_blank" rel="noopener">https://github.com/docker/docker</a></li>
<li><a href="https://wiki.openstack.org/wiki/Docker" target="_blank" rel="noopener">https://wiki.openstack.org/wiki/Docker</a></li>
<li><a href="https://wiki.archlinux.org/index.php/Docker" target="_blank" rel="noopener">https://wiki.archlinux.org/index.php/Docker</a></li>
</ul>

      </div>
    
  </div>

</article>

<button class="assist-btn2 circle" id="assist_btn2" title="点亮屏幕" style="left: 27px; top: 152px;">
  <i class="iconfont" style="display:inline-block;color:red;width:20px;height:20px;">&#xe61d;</i>
</button>
<button class="assist-btn1 circle" id="assist_btn1" title="关闭屏幕亮度" style="left: 27px; top: 152px;">
  <i class="iconfont toc-title" style="display:inline-block;color:red;width:20px;height:20px;">&#xe61d;</i>
</button>


<script src="//cdn.bootcss.com/jquery/3.1.1/jquery.min.js"></script>	

<script src="https://my.openwrite.cn/js/readmore.js" type="text/javascript"></script>
<script>
  const btw = new BTWPlugin();
  btw.init({
    id: "container",
    blogId: "22699-1592137983091-414",
    name: "前端进阶之旅",
    qrcode: "https://poetries1.gitee.io/img-repo/2020/06/qrcode.jpg",
    keyword: "3a3b3c",
  });
</script>

<script type="text/javascript">

// white theme
var body = {color: "#555", background: "#000"};
var a_tag = {color: "#222"};
var header = { background: "#222"};
var logo_line_i = {background: "#222"};
// var post_code = {background: "#eee", color: "#222"};

function switch_theme() {
 $("body").css(body);
 $("a:not('.links-of-author-item a, .site-state-item a, .site-state-posts a, .feed-link a, .motion-element a, .post-tags a, .show-commit-cls a, #donate_board a')").css(a_tag);
 $(".header, .footer").css(header);
 $(".logo-line-before i, .logo-line-after i").css(logo_line_i);
 //$(".post code").css(post_code);
 $("#idhyt-surprise-ball #idhyt-surprise-ball-animation .drag").css(a_tag);
 $(".post-title-link, .posts-expand .post-meta, .post-comments-count, .disqus-comment-count, .post-category a, .post-nav-next a, .post-nav-item a").css(a_tag);
 
 // $("code").css({color: '#c5c8c6', background: '#1d1f21'});
 //$("#assist_btn1").hide(1500);
}

$(function () {
$("#assist_btn2").css("display","none");
 $("#assist_btn1").click(function() {
     switch_theme();
$("div#toc.toc-article").css({
 "background":"#eaeaea",
 "opacity":1
});
$(".toc-article ol").show();
$("#toc.toc-article .toc-title").css("color","#a98602");
$("#assist_btn1").css("display","none");
$("#assist_btn2").css("display","block");
 });
$("#assist_btn2").click(function() {
$("#assist_btn2").css("display","none");
$("#assist_btn1").css("display","block");
$("body").css("background","url(http://www.miaov.com/static/ie/images/news/bg.png)")
     $(".header, .footer").css("background","url(http://www.miaov.com/static/ie/images/news/bg.png)")
$(".toc-article ol").toggle(1000);
 });
});


//背景随机

var Y, O, E, L, B, C, T, z, N, S, A, I;
!function() {
var e = function() {
for (O.clearRect(0, 0, L, B), T = [{
x: 0,
y: .7 * B + C
}, {
x: 0,
y: .7 * B - C
}]; T[1].x < L + C;) t(T[0], T[1])
}, t = function(e, t) {
O.beginPath(), O.moveTo(e.x, e.y), O.lineTo(t.x, t.y);
var n = t.x + (2 * I() - .25) * C,
 r = a(t.y);
O.lineTo(n, r), O.closePath(), N -= S / -50, O.fillStyle = "#" + (127 * A(N) + 128 << 16 | 127 * A(N + S / 3) + 128 << 8 | 127 * A(N + S / 3 * 2) + 128).toString(16), O.fill(), T[0] = T[1], T[1] = {
 x: n,
 y: r
}
}, a = function n(e) {
var t = e + (2 * I() - 1.1) * C;
return t > B || t < 0 ? n(e) : t
};
Y = document.getElementById("evanyou"), O = Y.getContext("2d"), E = window.devicePixelRatio || 1, L = window.innerWidth, B = window.innerHeight, C = 90, z = Math, N = 0, S = 2 * z.PI, A = z.cos, I = z.random, Y.width = L * E, Y.height = B * E, O.scale(E, E), O.globalAlpha = .6, document.onclick = e, document.ontouchstart = e, e()
}()

   
$("#toc-eye").click(function(){
$("#toc.toc-article").toggle(1000);
});

</script>


   
  <div class="text-center donation">
    <div class="inner-donation">
      <span class="btn-donation">支持一下</span>
      <div class="donation-body">
        <div class="tip text-center">扫一扫，支持poetries</div>
        <ul>
        
          <li class="item">
            
              <span>微信扫一扫</span>
            
            <img src="/images/weixin.jpg" alt="">
          </li>
        
          <li class="item">
            
              <span>支付宝扫一扫</span>
            
            <img src="/images/zhifubao.jpg" alt="">
          </li>
        
        </ul>
      </div>
    </div>
  </div>


   
  <div class="box-prev-next clearfix">
    <a class="show pull-left" href="/2018/11/20/docker-base/">
        <i class="icon icon-angle-left"></i>
    </a>
    <a class="show pull-right" href="/2018/11/20/nginx-config/">
        <i class="icon icon-angle-right"></i>
    </a>
  </div>




</div>


  <a id="backTop" class="back-top">
    <i class="icon-angle-up"></i>
  </a>




  <div class="modal" id="modal">
  <span id="cover" class="cover hide"></span>
  <div id="modal-dialog" class="modal-dialog hide-dialog">
    <div class="modal-header">
      <span id="close" class="btn-close">关闭</span>
    </div>
    <hr>
    <div class="modal-body">
      <ul class="list-toolbox">
        
          <li class="item-toolbox">
            <a
              class="CIRCLE"
              href="/archives/"
              rel="noopener noreferrer"
              target="_self"
              >
              博客
            </a>
          </li>
        
          <li class="item-toolbox">
            <a
              class="CIRCLE"
              href="/categories/"
              rel="noopener noreferrer"
              target="_self"
              >
              分类
            </a>
          </li>
        
          <li class="item-toolbox">
            <a
              class="CIRCLE"
              href="/tags/"
              rel="noopener noreferrer"
              target="_self"
              >
              标签
            </a>
          </li>
        
          <li class="item-toolbox">
            <a
              class="CIRCLE"
              href="/search/"
              rel="noopener noreferrer"
              target="_self"
              >
              搜索
            </a>
          </li>
        
          <li class="item-toolbox">
            <a
              class="CIRCLE"
              href="/link/"
              rel="noopener noreferrer"
              target="_self"
              >
              友链
            </a>
          </li>
        
          <li class="item-toolbox">
            <a
              class="CIRCLE"
              href="/about/"
              rel="noopener noreferrer"
              target="_self"
              >
              关于
            </a>
          </li>
        
      </ul>

    </div>
  </div>
</div>



  
      <div class="fexo-comments comments-post">
    

    

    
    

    

    
    

    

<!-- Gitalk评论插件通用代码 -->
<div id="gitalk-container"></div>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.css">
<script src="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js"></script>
<script>
const gitalk = new Gitalk({
  clientID: '5567a2c4abb858009d96',
  clientSecret: 'b9039ec056cf5c2346b3cdb63308a28c163f91e5',
  repo: 'poetries.github.io',
  owner: 'poetries',
  // 在这里设置一下截取前50个字符串, 这是因为 github 对 label 的长度有了要求, 如果超过
  // 50个字符串则会报错.
  // id: location.pathname.split('/').pop().substring(0, 49),
  id: location.pathname,
  admin: ['poetries'],
  // facebook-like distraction free mode
  distractionFreeMode: false
})
gitalk.render('gitalk-container')
</script>
<!-- Gitalk代码结束 -->



  </div>

  

  <script type="text/javascript">
  function loadScript(url, callback) {
    var script = document.createElement('script')
    script.type = 'text/javascript';

    if (script.readyState) { //IE
      script.onreadystatechange = function() {
        if (script.readyState == 'loaded' ||
          script.readyState == 'complete') {
          script.onreadystatechange = null;
          callback();
        }
      };
    } else { //Others
      script.onload = function() {
        callback();
      };
    }

    script.src = url;
    document.getElementsByTagName('head')[0].appendChild(script);
  }

  window.onload = function() {
    loadScript('/js/bundle.js?235683', function() {
      // load success
    });
  }
</script>


  <!-- 页面点击小红心 -->
  <script type="text/javascript" src="/js/clicklove.js"></script>
 
  
</body>
</html>
